import axios from "../../request/index";
import { Toast } from "vant";
export default {
  namespaced: true,
  //存数据
  state: {
    uid: "",
  },
  //同步进行修改
  mutations: {
    SET_UID(state, { uid }) {
      state.uid = uid;

      sessionStorage.setItem("uid", state.uid);
    },
  },
  //发起异步任务
  actions: {
    getUid({ commit }, { phone, password }) {
      axios
        .post("/api/api/userlog/logincode.do", {
          phone,
          password,
        })
        .then((res) => {
          console.log(res);

          this.router.push("/home/my");
          commit("SET_UID", {
            uid: res.data.data,
          });
        })
        .catch((res) => {
          console.log(res.data);
        });
    },
  },
};
